﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiDrawable : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiDrawable(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiDrawable_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiDrawable obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiDrawable()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiDrawable(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdGiDrawable() : this(GlobalsPINVOKE.new_OdGiDrawable(), MemoryManager.GetMemoryManager().GetCurrentTransaction() == null)
		{
			MemoryTransaction currentTransaction = MemoryManager.GetMemoryManager().GetCurrentTransaction();
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdGiDrawable(this.swigCPtr.Handle, true));
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		public new static OdGiDrawable cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiDrawable_cast(OdRxObject.getCPtr(pObj));
			OdGiDrawable result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiDrawable_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("isA", OdGiDrawable.swigMethodTypes1) ? GlobalsPINVOKE.OdGiDrawable_isASwigExplicitOdGiDrawable(this.swigCPtr) : GlobalsPINVOKE.OdGiDrawable_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("queryX", OdGiDrawable.swigMethodTypes0) ? GlobalsPINVOKE.OdGiDrawable_queryXSwigExplicitOdGiDrawable(this.swigCPtr, OdRxClass.getCPtr(protocolClass)) : GlobalsPINVOKE.OdGiDrawable_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiDrawable createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiDrawable_createObject();
			OdGiDrawable result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiDrawable.DrawableType drawableType()
		{
			OdGiDrawable.DrawableType result = (OdGiDrawable.DrawableType)(this.SwigDerivedClassHasMethod("drawableType", OdGiDrawable.swigMethodTypes2) ? GlobalsPINVOKE.OdGiDrawable_drawableTypeSwigExplicitOdGiDrawable(this.swigCPtr) : GlobalsPINVOKE.OdGiDrawable_drawableType(this.swigCPtr));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint setAttributes(OdGiDrawableTraits pTraits)
		{
			uint result = GlobalsPINVOKE.OdGiDrawable_setAttributes(this.swigCPtr, OdGiDrawableTraits.getCPtr(pTraits));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool worldDraw(OdGiWorldDraw pWd)
		{
			bool result = GlobalsPINVOKE.OdGiDrawable_worldDraw(this.swigCPtr, OdGiWorldDraw.getCPtr(pWd));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void viewportDraw(OdGiViewportDraw pVd)
		{
			GlobalsPINVOKE.OdGiDrawable_viewportDraw(this.swigCPtr, OdGiViewportDraw.getCPtr(pVd));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isPersistent()
		{
			bool result = GlobalsPINVOKE.OdGiDrawable_isPersistent(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbStub id()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGiDrawable_id(this.swigCPtr);
			OdDbStub result = (intPtr == IntPtr.Zero) ? null : new OdDbStub(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setGsNode(OdGsCache pGsNode)
		{
			GlobalsPINVOKE.OdGiDrawable_setGsNode(this.swigCPtr, OdGsCache.getCPtr(pGsNode));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGsCache gsNode()
		{
			OdGsCache result = (OdGsCache)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiDrawable_gsNode(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint viewportDrawLogicalFlags(OdGiViewportDraw pVd)
		{
			uint result = GlobalsPINVOKE.OdGiDrawable_viewportDrawLogicalFlags(this.swigCPtr, OdGiViewportDraw.getCPtr(pVd));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getGeomExtents(OdGeExtents3d extents)
		{
			OdResult result = (OdResult)(this.SwigDerivedClassHasMethod("getGeomExtents", OdGiDrawable.swigMethodTypes7) ? GlobalsPINVOKE.OdGiDrawable_getGeomExtentsSwigExplicitOdGiDrawable(this.swigCPtr, OdGeExtents3d.getCPtr(extents)) : GlobalsPINVOKE.OdGiDrawable_getGeomExtents(this.swigCPtr, OdGeExtents3d.getCPtr(extents)));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint regenSupportFlags()
		{
			uint result = GlobalsPINVOKE.OdGiDrawable_regenSupportFlags(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		protected virtual uint subSetAttributes(OdGiDrawableTraits traits)
		{
			uint result = GlobalsPINVOKE.OdGiDrawable_subSetAttributes(this.swigCPtr, OdGiDrawableTraits.getCPtr(traits));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		protected virtual bool subWorldDraw(OdGiWorldDraw wd)
		{
			bool result = GlobalsPINVOKE.OdGiDrawable_subWorldDraw(this.swigCPtr, OdGiWorldDraw.getCPtr(wd));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		protected virtual void subViewportDraw(OdGiViewportDraw vd)
		{
			GlobalsPINVOKE.OdGiDrawable_subViewportDraw(this.swigCPtr, OdGiViewportDraw.getCPtr(vd));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		protected virtual uint subViewportDrawLogicalFlags(OdGiViewportDraw vd)
		{
			uint result = this.SwigDerivedClassHasMethod("subViewportDrawLogicalFlags", OdGiDrawable.swigMethodTypes11) ? GlobalsPINVOKE.OdGiDrawable_subViewportDrawLogicalFlagsSwigExplicitOdGiDrawable(this.swigCPtr, OdGiViewportDraw.getCPtr(vd)) : GlobalsPINVOKE.OdGiDrawable_subViewportDrawLogicalFlags(this.swigCPtr, OdGiViewportDraw.getCPtr(vd));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		protected virtual uint subRegenSupportFlags()
		{
			uint result = this.SwigDerivedClassHasMethod("subRegenSupportFlags", OdGiDrawable.swigMethodTypes12) ? GlobalsPINVOKE.OdGiDrawable_subRegenSupportFlagsSwigExplicitOdGiDrawable(this.swigCPtr) : GlobalsPINVOKE.OdGiDrawable_subRegenSupportFlags(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("queryX", OdGiDrawable.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdGiDrawable.SwigDelegateOdGiDrawable_0(this.SwigDirectorqueryX);
			}
			if (this.SwigDerivedClassHasMethod("isA", OdGiDrawable.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdGiDrawable.SwigDelegateOdGiDrawable_1(this.SwigDirectorisA);
			}
			if (this.SwigDerivedClassHasMethod("drawableType", OdGiDrawable.swigMethodTypes2))
			{
				this.swigDelegate2 = new OdGiDrawable.SwigDelegateOdGiDrawable_2(this.SwigDirectordrawableType);
			}
			if (this.SwigDerivedClassHasMethod("isPersistent", OdGiDrawable.swigMethodTypes3))
			{
				this.swigDelegate3 = new OdGiDrawable.SwigDelegateOdGiDrawable_3(this.SwigDirectorisPersistent);
			}
			if (this.SwigDerivedClassHasMethod("id", OdGiDrawable.swigMethodTypes4))
			{
				this.swigDelegate4 = new OdGiDrawable.SwigDelegateOdGiDrawable_4(this.SwigDirectorid);
			}
			if (this.SwigDerivedClassHasMethod("setGsNode", OdGiDrawable.swigMethodTypes5))
			{
				this.swigDelegate5 = new OdGiDrawable.SwigDelegateOdGiDrawable_5(this.SwigDirectorsetGsNode);
			}
			if (this.SwigDerivedClassHasMethod("gsNode", OdGiDrawable.swigMethodTypes6))
			{
				this.swigDelegate6 = new OdGiDrawable.SwigDelegateOdGiDrawable_6(this.SwigDirectorgsNode);
			}
			if (this.SwigDerivedClassHasMethod("getGeomExtents", OdGiDrawable.swigMethodTypes7))
			{
				this.swigDelegate7 = new OdGiDrawable.SwigDelegateOdGiDrawable_7(this.SwigDirectorgetGeomExtents);
			}
			if (this.SwigDerivedClassHasMethod("subSetAttributes", OdGiDrawable.swigMethodTypes8))
			{
				this.swigDelegate8 = new OdGiDrawable.SwigDelegateOdGiDrawable_8(this.SwigDirectorsubSetAttributes);
			}
			if (this.SwigDerivedClassHasMethod("subWorldDraw", OdGiDrawable.swigMethodTypes9))
			{
				this.swigDelegate9 = new OdGiDrawable.SwigDelegateOdGiDrawable_9(this.SwigDirectorsubWorldDraw);
			}
			if (this.SwigDerivedClassHasMethod("subViewportDraw", OdGiDrawable.swigMethodTypes10))
			{
				this.swigDelegate10 = new OdGiDrawable.SwigDelegateOdGiDrawable_10(this.SwigDirectorsubViewportDraw);
			}
			if (this.SwigDerivedClassHasMethod("subViewportDrawLogicalFlags", OdGiDrawable.swigMethodTypes11))
			{
				this.swigDelegate11 = new OdGiDrawable.SwigDelegateOdGiDrawable_11(this.SwigDirectorsubViewportDrawLogicalFlags);
			}
			if (this.SwigDerivedClassHasMethod("subRegenSupportFlags", OdGiDrawable.swigMethodTypes12))
			{
				this.swigDelegate12 = new OdGiDrawable.SwigDelegateOdGiDrawable_12(this.SwigDirectorsubRegenSupportFlags);
			}
			GlobalsPINVOKE.OdGiDrawable_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1, this.swigDelegate2, this.swigDelegate3, this.swigDelegate4, this.swigDelegate5, this.swigDelegate6, this.swigDelegate7, this.swigDelegate8, this.swigDelegate9, this.swigDelegate10, this.swigDelegate11, this.swigDelegate12);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdGiDrawable));
		}

		private IntPtr SwigDirectorqueryX(IntPtr protocolClass)
		{
			return OdRxObject.getCPtr(this.queryX((OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(protocolClass, false))).Handle;
		}

		private IntPtr SwigDirectorisA()
		{
			return OdRxClass.getCPtr(this.isA()).Handle;
		}

		private int SwigDirectordrawableType()
		{
			return (int)this.drawableType();
		}

		private bool SwigDirectorisPersistent()
		{
			return this.isPersistent();
		}

		private IntPtr SwigDirectorid()
		{
			return OdDbStub.getCPtr(this.id()).Handle;
		}

		private void SwigDirectorsetGsNode(IntPtr pGsNode)
		{
			this.setGsNode(new OdGsCache(pGsNode, false));
		}

		private IntPtr SwigDirectorgsNode()
		{
			return OdGsCache.getCPtr(this.gsNode()).Handle;
		}

		private int SwigDirectorgetGeomExtents(IntPtr extents)
		{
			return (int)this.getGeomExtents(new OdGeExtents3d(extents, false));
		}

		private uint SwigDirectorsubSetAttributes(IntPtr traits)
		{
			return this.subSetAttributes(new OdGiDrawableTraits(traits, false));
		}

		private bool SwigDirectorsubWorldDraw(IntPtr wd)
		{
			return this.subWorldDraw(new OdGiWorldDraw_Internal(wd, false));
		}

		private void SwigDirectorsubViewportDraw(IntPtr vd)
		{
			this.subViewportDraw(new OdGiViewportDraw_Internal(vd, false));
		}

		private uint SwigDirectorsubViewportDrawLogicalFlags(IntPtr vd)
		{
			return this.subViewportDrawLogicalFlags(new OdGiViewportDraw_Internal(vd, false));
		}

		private uint SwigDirectorsubRegenSupportFlags()
		{
			return this.subRegenSupportFlags();
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		private OdGiDrawable.SwigDelegateOdGiDrawable_0 swigDelegate0;

		private OdGiDrawable.SwigDelegateOdGiDrawable_1 swigDelegate1;

		private OdGiDrawable.SwigDelegateOdGiDrawable_2 swigDelegate2;

		private OdGiDrawable.SwigDelegateOdGiDrawable_3 swigDelegate3;

		private OdGiDrawable.SwigDelegateOdGiDrawable_4 swigDelegate4;

		private OdGiDrawable.SwigDelegateOdGiDrawable_5 swigDelegate5;

		private OdGiDrawable.SwigDelegateOdGiDrawable_6 swigDelegate6;

		private OdGiDrawable.SwigDelegateOdGiDrawable_7 swigDelegate7;

		private OdGiDrawable.SwigDelegateOdGiDrawable_8 swigDelegate8;

		private OdGiDrawable.SwigDelegateOdGiDrawable_9 swigDelegate9;

		private OdGiDrawable.SwigDelegateOdGiDrawable_10 swigDelegate10;

		private OdGiDrawable.SwigDelegateOdGiDrawable_11 swigDelegate11;

		private OdGiDrawable.SwigDelegateOdGiDrawable_12 swigDelegate12;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdRxClass)
		};

		private static Type[] swigMethodTypes1 = new Type[0];

		private static Type[] swigMethodTypes2 = new Type[0];

		private static Type[] swigMethodTypes3 = new Type[0];

		private static Type[] swigMethodTypes4 = new Type[0];

		private static Type[] swigMethodTypes5 = new Type[]
		{
			typeof(OdGsCache)
		};

		private static Type[] swigMethodTypes6 = new Type[0];

		private static Type[] swigMethodTypes7 = new Type[]
		{
			typeof(OdGeExtents3d)
		};

		private static Type[] swigMethodTypes8 = new Type[]
		{
			typeof(OdGiDrawableTraits)
		};

		private static Type[] swigMethodTypes9 = new Type[]
		{
			typeof(OdGiWorldDraw)
		};

		private static Type[] swigMethodTypes10 = new Type[]
		{
			typeof(OdGiViewportDraw)
		};

		private static Type[] swigMethodTypes11 = new Type[]
		{
			typeof(OdGiViewportDraw)
		};

		private static Type[] swigMethodTypes12 = new Type[0];

		public delegate IntPtr SwigDelegateOdGiDrawable_0(IntPtr protocolClass);

		public delegate IntPtr SwigDelegateOdGiDrawable_1();

		public delegate int SwigDelegateOdGiDrawable_2();

		public delegate bool SwigDelegateOdGiDrawable_3();

		public delegate IntPtr SwigDelegateOdGiDrawable_4();

		public delegate void SwigDelegateOdGiDrawable_5(IntPtr pGsNode);

		public delegate IntPtr SwigDelegateOdGiDrawable_6();

		public delegate int SwigDelegateOdGiDrawable_7(IntPtr extents);

		public delegate uint SwigDelegateOdGiDrawable_8(IntPtr traits);

		public delegate bool SwigDelegateOdGiDrawable_9(IntPtr wd);

		public delegate void SwigDelegateOdGiDrawable_10(IntPtr vd);

		public delegate uint SwigDelegateOdGiDrawable_11(IntPtr vd);

		public delegate uint SwigDelegateOdGiDrawable_12();

		[Flags]
		public enum SetAttributesFlags
		{
			kDrawableNone = 0,
			kDrawableIsAnEntity = 1,
			kDrawableUsesNesting = 2,
			kDrawableIsCompoundObject = 4,
			kDrawableViewIndependentViewportDraw = 8,
			kDrawableIsInvisible = 16,
			kDrawableHasAttributes = 32,
			kDrawableRegenTypeDependantGeometry = 64,
			kDrawableIsDimension = 133,
			kDrawableRegenDraw = 256,
			kDrawableStandardDisplaySingleLOD = 512,
			kDrawableShadedDisplaySingleLOD = 1024,
			kDrawableViewDependentViewportDraw = 2048,
			kDrawableBlockDependentViewportDraw = 4096,
			kDrawableIsExternalReference = 8192,
			kDrawableNotPlottable = 16384,
			kLastFlag = 16384
		}

		public enum DrawableType
		{
			kGeometry,
			kDistantLight,
			kPointLight,
			kSpotLight,
			kAmbientLight,
			kSolidBackground,
			kGradientBackground,
			kImageBackground,
			kGroundPlaneBackground,
			kViewport,
			kWebLight,
			kSkyBackground,
			kImageBasedLightingBackground
		}
	}
}
